<template>
  <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="700px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
      <el-form-item label="用户头像">
        <el-input v-model="form.userIcon" />
      </el-form-item>
      <el-form-item label="用户名" prop="userName">
        <el-input v-model="form.userName" />
      </el-form-item>
      <el-form-item label="用户手机号" prop="userPhone">
        <el-input v-model="form.userPhone" />
      </el-form-item>
      <el-form-item label="用户邮箱">
        <el-input v-model="form.userEmail" />
      </el-form-item>
      <el-form-item label="用户密码">
        <el-input v-model="form.userPwd" />
      </el-form-item>
      <el-form-item label="用户激活状态">
        <el-select v-model="form.userActiveStatus" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.user_active_status" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item label="用户状态">
        <el-select v-model="form.userStatus" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.user_auth_status" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item label="用户状态备注">
        <el-input v-model="form.userStatusRemark" />
      </el-form-item>
      <el-form-item label="用户添加渠道">
        <el-select v-model="form.userRegisterChannel" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.user_channel" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="crud.cancelCU">取消</el-button>
      <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { form } from '@crud/crud'

const defaultForm = { userId: null, userIcon: null, userName: null, userPhone: null, userEmail: null, userPwd: null, userPwdSalt: null, userActiveStatus: null, userStatus: null, userStatusRemark: null, userRegisterTime: null, userRegisterChannel: null, userLastLoginTime: null, userLastLoginIp: null }
export default {
  mixins: [form(defaultForm)],
  props: {
    dict: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      rules: {
        userName: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
        userPhone: [{ required: true, message: '用户手机号不能为空', trigger: 'blur' }]
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
